Ch 9 Linear Equation

UTG

CPE 332

Computer Engineering

Mathematics II

Week 12

Part III, Chapter 10

Linear Equations

Today(Week 13) Topics

• Chapter 9 Linear Equations

– Gauss Elimination

– Gauss-Jordan

– Gauss-Seidel

– LU Decomposition

– Crout Decomposition

• HW(9) Ch 9 Due Next Week

MATLAB Programming

• เราสามารถเขียน Function การคํานวณโดยใช ้ MATLAB

Editor และบันทึกเป็น ‘.m’ File

– ขึ้นบันทัดแรกของ Function ด ้วย

function [List ของค่าที่ส่งคืน]=fname(List ของ Parameter) function [x,y,z]=find123(a,b,c)

– ภายใน Function สามารถใช ้ Loop, Branch ได ้เหมือนการ

เขียนโปรแกรม, สามารถกําหนด Local Variable ภายในได ้

เช่นกัน

– อย่าลืมว่า พื้นฐาน Variable จะเป็น Matrix

• Function นี้สามารถเรียกใช ้งานได ้ใน MATLAB

• ดูรายละเอียดใน Tutorial 4-5 ของ MATLAB

Ex: หารากของ

− cos x

− sin x

f ( x) = sin 3 x e

+ cos 2 x e

x=-10:.1:10;

y=sin(3*x).*exp(-cos(x))+cos(2*x).*exp(-sin(x));

plot(x,y)

เราจะหาคําตอบในช่วง [0, 2]

x =0.95774795776341

MATLAB: Bisection Mtd.

function [x]=example91a(es)

% Calculate using Bisection Method between [0,2]

ea = inf;

xr = inf;

it=0;

xl=0;

xu=2;

while(ea > es)

it = it+1;

pxr=xr;

fxl=sin(3*xl).*exp(-cos(xl))+cos(2*xl).*exp(-sin(xl));

fxu=sin(3*xu).*exp(-cos(xu))+cos(2*xu).*exp(-sin(xu));

xr=(xl+xu)/2;

fxr=sin(3*xr).*exp(-cos(xr))+cos(2*xr).*exp(-sin(xr));

ea = abs((xr-pxr)/xr)*100;

x=[it xl fxl xu fxu xr fxr ea]

if(fxl*fxr > 0.0)

xl=xr;

elseif (fxl*fxr < 0.0)

xu=xr;

else

ea=0.0;

end

end

Bisection Results:>> example91a(0.01) Iter xl fxl xu fxu xr fxr ea

x = 1.0000 0 1.0000 2.0000 -0.6869 1.0000 -0.0972 Inf

x = 2.0000 0 1.0000 1.0000 -0.0972 0.5000 0.7493 100.0000

x = 3.0000 0.5000 0.7493 1.0000 -0.0972 0.7500 0.4101 33.3333

x = 4.0000 0.7500 0.4101 1.0000 -0.0972 0.8750 0.1774 14.2857

x = 5.0000 0.8750 0.1774 1.0000 -0.0972 0.9375 0.0451 6.6667

x = 6.0000 0.9375 0.0451 1.0000 -0.0972 0.9688 -0.0249 3.2258

x = 7.0000 0.9375 0.0451 0.9688 -0.0249 0.9531 0.0104 1.6393

x = 8.0000 0.9531 0.0104 0.9688 -0.0249 0.9609 -0.0072 0.8130

x = 9.0000 0.9531 0.0104 0.9609 -0.0072 0.9570 0.0016 0.4082

x = 10.0000 0.9570 0.0016 0.9609 -0.0072 0.9590 -0.0028 0.2037

x = 11.0000 0.9570 0.0016 0.9590 -0.0028 0.9580 -0.0006 0.1019

x = 12.0000 0.9570 0.0016 0.9580 -0.0006 0.9575 0.0005 0.0510

x = 13.0000 0.9575 0.0005 0.9580 -0.0006 0.9578 -0.0000 0.0255

x = 14.0000 0.9575 0.0005 0.9578 -0.0000 0.9576 0.0002 0.0127

x = 15.0000 0.9576 0.0002 0.9578 -0.0000 0.9577 0.0001 0.0064

ans =

15.00000000000000 0.95776367187500 -0.00003535871565 0.95770263671875

0.00023929892750 0.95770263671875 0.00010197464576 0.00637308010962

x =0.95774795776341

True error = 0.004732%

Other Results: xt= 0.95774795776341

• Es = 0.01%

– It = 15;xr=0.95770263671875

– Ea=0.006373%, et = 0.004732%

• Es = Es = 0.001%

– It = 18;xr=0.95774078369141

– Ea=0.0007966%, et = 0.0007491%

• Es = 0.0001%

– It = 21;xr=0.95774745941162

– Ea=0.00009957%, et = 0.00005203%

• Es = 0.000001%

– It = 28;xr=0.95774795860052

– Ea=0.0000007779%, et = 8.740e-008%

MATLAB: False-Position

function [x]=example91b(es)

% Calculate using False-Position Method between [0,2]

ea = inf;

xr = inf;

it=0;

xl=0;

xu=2;

while(ea > es)

it = it+1;

pxr=xr;

fxl=sin(3*xl).*exp(-cos(xl))+cos(2*xl).*exp(-sin(xl));

fxu=sin(3*xu).*exp(-cos(xu))+cos(2*xu).*exp(-sin(xu));

% xr=(xl+xu)/2;

xr=xu-((fxu*(xl-xu))/(fxl-fxu));

fxr=sin(3*xr).*exp(-cos(xr))+cos(2*xr).*exp(-sin(xr));

ea = abs((xr-pxr)/xr)*100;

x=[it xl fxl xu fxu xr fxr ea]

if(fxl*fxr > 0.0)

xl=xr;

elseif (fxl*fxr < 0.0)

xu=xr;

else

ea=0.0;

end

end

FP Results:>> example91b(0.01) Iter xl fxl xu fxu xr fxr ea

x = 1.0000 0 1.0000 2.0000 -0.6869 1.1856 -0.5611 Inf

x = 2.0000 0 1.0000 1.1856 -0.5611 0.7595 0.3940 56.1096

x = 3.0000 0.7595 0.3940 1.1856 -0.5611 0.9353 0.0500 18.7964

x = 4.0000 0.9353 0.0500 1.1856 -0.5611 0.9557 0.0045 2.1423

x = 5.0000 0.9557 0.0045 1.1856 -0.5611 0.9576 0.0004 0.1922

x = 6.0000 0.9576 0.0004 1.1856 -0.5611 0.9577 0.0000 0.0166

x = 7.0000 0.9577 0.0000 1.1856 -0.5611 0.9577 0.0000 0.0014

ans =

7.00000000000000 0.95773289766706 0.00003388653487 1.18559512875289

-0.56109590391892 0.95774665822935 0.00000292408716 0.00143676432376

x =0.95774795776341

True error = 0.0001357 %

Other Results: xt= 0.95774795776341

• สีนํ้าเงินได ้จาก Bisection Method

• สีเขียวได ้จาก False-Position Method

• Es = 0.01%

– It = 15;xr=0.95770263671875 Ea=0.006373%, et = 0.004732%

– It = 7;xr=0.95774665822935 Ea=0.001437%, et = 0.0001357%

• Es = Es = 0.001%

– It = 18;xr=0.95774078369141 Ea=0.0007966%, et = 0.0007491%

– It = 8;xr=0.95774784562942 Ea=0.0001240%, et = 0.00001171%

• Es = 0.0001%

– It = 21;xr=0.95774745941162 Ea=0.00009957%, et = 0.00005203%

– It = 9;xr=0.95774794808763 Ea=0.00001070%, et = 0.000001010%

• Es = 0.000001%

– It = 28;xr=0.95774795860052 Ea=0.0000007779%, et = 8.740e-008%

– It = 10;xr=0.95774795692851 Ea=0.0000009231%, et = 8.717e-008%

Newton-Ralphson Method

f ( x) = sin3

− cos

x e

x + cos2

− sin

x e

x

−cos

e

x

sin 3

−sin

x

e

x

x

x

x

cos

sin

cos2

f '( x) = sin 3 x d

+ e

d

+ cos2 x d

+ e

d

dx

dx

dx

dx

= sin3

−cos

x e

x ⋅ sin

−cos

x + e

x ⋅ 3cos3 x + cos2

−sin

x e

x (−cos x)

−sin

+ e

x ⋅ ( 2

− sin 2 x)

−cos

= e

x [sin 3 x sin x + 3cos3 x]

−sin

e

x [cos 2 x cos x + 2sin 2 x]

f ( x )

i

x

= x

i 1

+

i

f '( x )

i

sin 3

cos x

x e

i

+ cos2

sin x

x e

i

i

i

x

= x

i 1

+

i

−cos x

e

i [sin 3 x sin x + 3cos 3 x ]

sin x

e

i [cos 2 x cos x + 2sin 2 x ]

i

i

i

i

i

i

MATLAB Program:

function [x]=example91c(es,x0)

% Calculate solution using Newton-Ralphson, x0=initial;

it=0;

xi=x0;

ea=inf;

while (ea > es)

it = it+1;

fxi=sin(3*xi)*exp(-cos(xi))+cos(2*xi)*exp(-sin(xi));

dfxi=exp(-cos(xi))*(sin(3*xi)*sin(xi)+3*cos(3*xi))...

-exp(-sin(xi))*(cos(2*xi)*cos(xi)+2*sin(2*xi));

pxi=xi;

xi=pxi-fxi/dfxi;

ea=abs((xi-pxi)/xi)*100;

x=[it pxi fxi dfxi xi ea]

end

Result: ea=0.01, xo=?

• X0=0 โปรแกรมจะ Converge เข ้าสู่จุดอื่นด ้านซ ้าย

• X0=2 โปรแกรมจะ Converge เข ้าสู่จุดอื่นด ้านขวา

• ดูรูป

• ถ ้า x0 = 0.5 หรือ 1.5 โปรแกรมจะ Converge เข ้า

จุดที่ต ้องการอย่างรวดเร็วมาก

• เป็นไปได ้ที่เราเลือกจุดที่โปรแกรมไม่ Converge

• เราอาจจะใช ้ Bisection Method ก่อนเพื่อหาจุด

x0 ที่ดี จากนั้นต่อด ้วย Newton-Ralphson เพื่อให ้

ได ้คําตอบอย่างรวดเร็ว

เราจะหาคําตอบในช่วง [0, 2]

X0=0

x =0.95774795776341

2.1310

X0=2

Ex: หารากของ

− cos x

− sin x

f ( x) = sin 3 x e

+ cos 2 x e

x=-10:.1:10;

y=sin(3*x).*exp(-cos(x))+cos(2*x).*exp(-sin(x));

plot(x,y)

กรณีเลือก x0 = 0

-9.2837

Result: x0=0.5, es = 0.01

Iter xi fxi dfxi xi+1 ea

• x = 1.0000 0.5000 0.7493 -1.0485 1.2146 58.8351

• x = 2.0000 1.2146 -0.6362 -2.5824 0.9683 25.4413

• x = 3.0000 0.9683 -0.0238 -2.2755 0.9578 1.0939

• x = 4.0000 0.9578 -0.0001 -2.2502 0.9577 0.0061

• x = 4 0.95780651884294 -0.00013177280 -2.25024858111352

0.95774795962033 0.00611426231998

x =0.95774795776341

True error = 0.0000001939 %

Result: x0=0.5, es = 0.000001

Iter xi fxi dfxi xi+1 ea

• x = 1.0000 0.5000 0.7493 -1.0485 1.2146 58.8351

• x = 2.0000 1.2146 -0.6362 -2.5824 0.9683 25.4413

• x = 3.0000 0.9683 -0.0238 -2.2755 0.9578 1.0939

• x = 4.0000 0.9578 -0.0001 -2.2502 0.9577 0.0061

• x = 5.0000 0.9577 -0.0000 -2.2501 0.9577 0.0000

• x = 5 0.95774795962033 -0.00000000417826 -

2.25010587635298 0.95774795776341 0.00000019388349

x =0.95774795776341

True error = 0.000000000000000 %

Compare : xt =0.95774795776341

• Es = 0.01%

– It = 15;xr=0.95770263671875 Ea=0.006373%, et = 0.004732%

– It = 7;xr=0.95774665822935 Ea=0.001437%, et = 0.0001357%

– It = 4;xi= 0.95774795962033 Ea=0.006114%, et = 0.0000001939 %

• Es = Es = 0.001%

– It = 18;xr=0.95774078369141 Ea=0.0007966%, et = 0.0007491%

– It = 8;xr=0.95774784562942 Ea=0.0001240%, et = 0.00001171%

– It = 5;xi= 0.95774795776341 Ea=0.0000001939%, et < 1.0e-15 %

• Es = 0.0001%

– It = 21;xr=0.95774745941162 Ea=0.00009957%, et = 0.00005203%

– It = 9;xr=0.95774794808763 Ea=0.00001070%, et = 0.000001010%

– It = 5;xi= 0.95774795776341 Ea=0.0000001939%, et < 1.0e-15 %

• Es = 0.000001%

– It = 28;xr=0.95774795860052 Ea=0.0000007779%, et = 8.740e-008%

– It = 10;xr=0.95774795692851 Ea=0.0000009231%, et = 8.717e-008%

– It = 5;xi= 0.95774795776341 Ea=0.0000001939%, et < 1.0e-15 %

เพียง 5 iteration วิธีของ Newton-Ralphson

ให ้ Error น ้อยจน Double Precision วัดไม่ได ้

แต่ข ้อเสียคือจุด x0 จะต ้องเลือกให ้ดี

Chapter 10: System of

Linear Eq.

• จะ Limit อยู่ที่สมการ AX=B โดย A เป็น Square

Matrix

– N สมการ N Unknown

– จะมีคําตอบที่ Unique

– คําตอบจะมีได ้ต่อเมื่อ A ไม่เป็น Singular

• Determinant ไม่เท่ากับ 0

• A หา Inverse ได ้ และ X = A-1B

– ในกรณีที่ Determinant A ใกล ้ศูนย์ แต่ไม่ใช่ศูนย์

คําตอบจะ Sensitive กับ Error การคํานวณเมื่อมีการ

ปัดเศษจะต ้องระวัง

• กรณีนี้ เราเรียกว่ามันเป็น ‘Ill-Conditioned System’

System of Linear Equations

Krammer’s Rule

Solution ของ AX=C

• A-1AX=A-1C

• X=A-1C

• Inverse หาได ้ยาก แม ้จะใช ้ Computer

คํานวณ เพราะเป็น O(n4)

Solution by Elimination

Gauss Elimination

1. ใน Elimination Step จาก AX=C เราพยายามทําให ้

Matrix A อยู่ในรูป Upper Diagonal Matrix ด ้วย

ขบวนการ Elimination คือการบวกและลบแต่ละแถวเข ้า

ด ้วยกัน และค่า C จะถูกบวกลบตามไปด ้วย

2. เมื่อ A เป็น Upper Diagonal แล ้ว การแก ้สมการสามารถ

ทําได ้ง่าย โดยเราหา xn ก่อนในแถวสุดท ้ายของสมการ

จากนั้นนํา xn ที่หาได ้มาแทนค่า เพื่อหา xn-1 ในแถวรอง

สุดท ้าย เนื่องจากเป็นการแทนค่าเพื่อหา Unknown

ย ้อนหลัง เราจึงเรียก Back-Substitution

Gauss Elimination

• จาก

AX = C

Gauss Elimination

AX = C

a

a

a

x

c

1

,

1

,

1 2

,

1 n   1 

 1 

    

a

a

a

x

c

2 1

,

2,2

2, n   2 

 2

=

 

    

  

    

a

a

a

x

c

n 1

,

n,2

n, n   n

n

aˆ

aˆ

aˆ

x

cˆ

1

,

1

,

1 2

,

1 n   1 

 1 

    

a

aˆ

aˆ

x

cˆ

2 1

,

2,2

2, n   2 

 2

=

 

    

  

    

 0

0

aˆ

x

cˆ

n, n   n

n

Gauss Elimination

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1  1

    

a

a

a

a

a

x

c

2 1

,

2,2

2,3

2,4

2,5   2 

 2

a

a

a

a

a   x  =  c

 3 1,

3,2

3,3

3,4

3,5   3  3

a

a

a

a

a

x

c

4 1

,

4,2

4,3

4,4

4,5   4 

 4

 

a

a

a

a

a

x

c

 5 1,

5,2

5,3

5,4

5,5   5 

 5

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1  1 

/

/

/

/

    

 0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5   2 

 2

/

/

/

/

0

a

a

a

a   x  =  c' 

3,2

3,3

3,4

3,5 

/

/

/

/

 3  3

 0

a

a

a

a

x

c'

4,2

4,3

4,4

4,5   4 

 4

/

/

/

/

 

a

a

a

a

x

0

c' 

5,2

5,3

5,4

5,5   5 

 5 

Gauss Elimination

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1  1 

/

/

/

/

    

 0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5   2 

 2

/

/

/

/

0

a

a

a

a   x  =  c' 

3,2

3,3

3,4

3,5 

/

/

/

/

 3  3

 0

a

a

a

a

x

c'

4,2

4,3

4,4

4,5   4 

 4

/

/

/

/

 

a

a

a

a

x

0

c' 

5,2

5,3

5,4

5,5   5 

 5 

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1  1 

/

/

/

/

    

 0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5   2 

 2 

//

//

//

0

0

a

a

a   x  =  c'' 

3,3

3,4

3,5 

//

//

//

 3  3

 0

0

a

a

a

x

c''

4,3

4,4

4,5   4 

 4

//

//

//  

a

a

a

x

0

0

c'' 

5,3

5,4

5,5   5 

 5 

Gauss Elimination

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1   1 

/

/

/

/

   

 0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5   2 

 2 

//

//

//

0

0

a

a

a   x  =  c'' 

3,3

3,4

3,5 

//

//

//

 3  3

 0

0

a

a

a

x

c''

4,3

4,4

4,5   4 

 4

//

//

//  

a

a

a

x

0

0

c'' 

5,3

5,4

5,5   5 

 5 

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1   1 

/

/

/

/

   

 0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5   2 

 2 

//

//

//

0

0

a

a

a   x  =  c'' 

3,3

3,4

3,5 

///

///

 3  3 

 0

0

0

a

a

x

c'''

4,4

4,5   4 

 4

///

///  

a

a

x

0

0

0

c''' 

5,4

5,5   5 

 5 

Gauss Elimination

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1   1 

/

/

/

/

   

 0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5   2 

 2 

//

//

//

0

0

a

a

a   x  =  c'' 

3,3

3,4

3,5 

///

///

 3  3 

 0

0

0

a

a

x

c'''

4,4

4,5   4 

 4

///

///  

a

a

x

0

0

0

c''' 

5,4

5,5   5 

 5 

a

a

a

a

a x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

 1   1 

/

/

/

/

   

 0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5   2 

 2 

//

//

//

0

0

a

a

a

  x  =  c'' 

3,3

3,4

3,5 

(3)

(3)

 3  3

(3) 

 0

0

0

a

a

x

c

4,4

4,5   4 

 4 

(4)  

a

x

 (4)

c

 0

0

0

0

5,5   5 

 5 

Back Substitution

a

a

a

a

a   x

c

1

,

1

,

1 2

,

1 3

,

1 4

,

1 5

1

1

   

/

/

/

/

0

a

a

a

a

x

c'

2,2

2,3

2,4

2,5 

2

2

  

//

//

//

 0

0

a

a

a   x  =  c'' 

3,3

3,4

3,5

3

3

   

(3)

(3)

(3)

 0

0

0

a

a

x

c

4,4

4,5

 4  4 

(4)

(4)

0

0

0

0

a

x   c

5,5   5 

 5 

a x + a x + a x + a x + a x = c 1

,

1

1

,

1 2

2

,

1 3 3

,

1 4

4

,

1 5 5

1

/

/

/

/

a x + a x + a x + a x = c'

2,2

2

2,3 3

2,4

4

2,5 5

2

//

//

//

a x + a x + a x = c''

3,3 3

3,4

4

3,5 5

3

(3)

(3)

(3)

a x + a x = c

4,4

4

4,5 5

4

(4)

(4)

a

x = c

5,5

5

5

Back

a x + a x + a x + a x + a x = c 1

,

1

1

,

1 2

2

,

1 3 3

,

1 4

4

,

1 5 5

1

/

/

/

/

+

+

+

=

Substitution

a x

a x

a x

a x

c'

2,2

2

2,3 3

2,4

4

2,5 5

2

//

//

//

a x + a x + a x = c''

3,3 3

3,4

4

3,5 5

3

(3)

(3)

(3)

a x + a x = c

4,4

4

4,5 5

4

(4)

(4)

a

x = c

5,5

5

5

(4)

c 5

x =

5

(4)

a 5,5

(3)

(3)

c

a x

4

4,5 5

x =

4

(3)

a 4,4

//

//

c'' − a x a x

3

3,4

4

3,5 5

x =

3

//

a 3,3

/

/

/

c' − a x a x a x 2

2,3 3

2,4

4

2,5 5

x =

2

/

a 2,2

c a x a x a x a x 1

,

1 2

2

,

1 3 3

,

1 4

4

,

1 5 5

x =

1

a 1,

1

Gauss Elimination

Gauss Elimination

Gauss Elimination

Gauss Elimination

Gauss Elimination

Gauss Elimination Alg

• Elimination by Forward Substitution

Gauss Elimination Alg

• Back-Substitution

Gauss Elimination Alg

• Back-Substitution

Example 8.1

Example 8.1

Example 8.1

• Back Substitution

ปัญหาของ Gauss Elimination

ปัญหาของ Gauss Elimination

ปัญหาของ Gauss Elimination

ปัญหาของ Gauss Elimination

Gauss-Jordan Method

Gauss-Jordan Method

Example 8.2

Example 8.2

 3

− 0 1

.

− 2

.

0

|

7 85

.

 .

0 1

7

− 3

.

0

|

3

.

19

 .

0 3

− 0 2

.

10

|

4

.

71

( R )

2 − ( R )

1 × .1/ 3 → ( R )

2

 3

− .

0 1

− .

0 2

|

85

.

7

 0

0033

.

7

− 0 2933

.

|

5617

.

19

 3

.

0

− 0 2

.

10

|

.

71 4

( R )

3 − ( R )

1 × 3

. / 3 → ( R )

3

3

− 0 1

.

− 2

.

0

|

85

.

7

0

7 0033

.

− 0 2933

.

|

5617

.

19

0 − 0 1900

.

10 0200

.

|

6150

.

70

( R )

1 = ( R )

1 / 3

1 − 0333

.

0

− .

0 0667 |

6167

.

2

0

0033

.

7

− .

0 2933 |

5617

.

19

0 − 0 1900

.

.

10 0200

|

6150

.

70

Example 8.2

1.0000 − 0.0333 − 0 0667

.

|

.

2 6167 

 0

7 0033

.

− 0 2933

.

|

− .

19 5617

 0

− .

0 1900

.

10 0200

|

.

70 6150 

( R )

3 = ( R )

3 − ( R )

2 × (−.

)

19 / 7 0033

.

 .

1 0000

− .

0 0333

− 0 0667

.

|

.

2 6167 

 0

7.0033

− 0.2933 | −

5617

.

19

 0

0

.

10 0120

|

.

70 0843 

( R )

2 = ( R )

2 / 7 0033

.

1.0000 − .

0 0333

− .

0 0667 |

.

2 6167 

 0

1

− 0.0419 | − .

2 7932

 0

0

.

10 0120

|

0843

.

70

( R )

1 = ( R )

1 − ( R )

2 × (−

)

0333

.

 .

1 0000

0

− 0 0681

.

|

2 5236

.

 0

1.0000

− .

0 0419 |

− 2.7932

 0

0

0120

.

10

|

.

70 0843 

Example 8.2

 0000

.

1

0

− 0 0681

.

|

5236

.

2

 0

0000

.

1

− 0419

.

0

|

− 7932

.

2

 0

0

0120

.

10

|

70 0843

.

( R )

3 = ( R )

3 /

012

.

10

 0000

.

1

0

− 0681

.

0

|

5236

.

2

 0

0000

.

1

− 0419

.

0

|

− 7932

.

2

 0

0

1 0000

.

|

0000

.

7

( R )

2 = ( R )

2 − ( R )

3 * (−

)

0419

.

 0000

.

1

0

− 0681

.

0

|

5236

.

2

 0

.

1 0000

0

|

− 5000

.

2

 0

0

0000

.

1

|

0000

.

7

( R )

1 = ( R )

1 − ( R )

3 * (−

)

0681

.

 0000

.

1

0

0

|

0000

.

3

 0

0000

.

1

0

|

− 5000

.

2

 0

0

0000

.

1

|

0000

.

7

Example 8.2

 .

1 0000

0

0

|

.

3 0000 

0

.

1 0000

0

|

− 2 5000

.

 0

0

.

1 0000 |

.

7 0000 

A'X = C'

1

0

0  x

 3 

1

   

0

1

0

x

= − .

2 5

2

   

0 0 1  x   7 

  3 

x

= 3

1

x

= 2

− 5

.

2

x

= 7

3

Example 8.2

การหา Matrix Inverse ด ้วย GJ

การหา Matrix Inverse ด ้วย GJ

การหา Matrix Inverse ด ้วย GJ

การหา Matrix Inverse ด ้วย GJ

การหา Matrix Inverse ด ้วย GJ

Example 8.3

Example 8.3

Example 8.3

1

3

− 1

.

− 2

. −

 3325

.

.0049

0068

.

1

.

7

− 3

.

=

− .0052 .1429 .0042

.3 − 2

.

10 

− 0101

.

.0027 .0999

จํานวนการคํานวณจะใช ้น ้อยกว่าวิธีทาง Analytic Method มาก

AdjA

A 1 =

A

Iterative Method and

Gauss-Seidel

Gauss-Seidel

Gauss-Seidel

Gauss-Seidel

Gauss-Seidel

Gauss-Seidel

Gauss-Seidel: Ex 8.4

Gauss-Seidel: Ex 8.4

Gauss-Seidel: Ex 8.4

0

0

x = x = x =

1

2

0 0

3

+

x +

x

+

+

1

.

7 85

1

.

0

0

2

.

0

0

85

.

7

(

1

.

0

)

0

.

0 (

2 )

0

.

7 85

2

3

x =

=

=

= .

2 61667

1

3

3

3

x +

x

+

1

.

19 3

.

0 1 1

3

.

0

0

19 3

.

0 (

1

.

.

2 61667)

.

0 (

3 0)

.

19 56167

1

3

x =

=

=

= −2 79452

.

2

7

7

7

x +

x

+

1

.

71 4

3

.

0

1

0 2

.

1

.

71 4 0 (

3

. 2 61667

.

)

(

2

.

0

)

79452

.

2

056095

.

70

1

2

x =

=

=

= 00561

.

7

3

10

10

10

2 61667

.

− 0

e

=

×100 =

%

100

a 1

,

61667

.

2

− 2 79452

.

− 0

e

=

×100 =

%

100

a 1

,

− 79452

.

2

7 00561

.

− 0

e

=

×100 =

%

100

a 1

,

00561

.

7

Gauss-Seidel: Ex 8.4

1

x = 2

x = −

x =

1

61667

.

, 1

.

2

,

79452

1

.

7 00561

2

3

+

x +

x

+

+

2

7 85

.

.

0 1 1

.

0 2 1

7 85

.

.

0 (

1

.

2

)

79452

0 (

2

.

)

00561

.

7

8 971696

.

8

2

3

x =

=

=

= 99056

.

2

1

3

3

3

x +

x

+

2

.

19 3 0 1

.

2

3

.

0

1

3

.

19

0. (

1

)

99056

.

2

(

3

.

0

7

)

00561

.

17 49737

.

1

3

x =

=

=

= − 49962

.

2

2

7

7

7

x +

x

+

2

71 4

.

0 3

.

2

.

0 2 2

71 4

.

(

3

.

0

)

99056

.

2

(

2

.

0

2

)

49962

.

70 00291

.

1

2

x =

=

=

= 00029

.

7

3

10

10

10

.

2 99056 − .

2 61667

e

=

×100 =

%

50

.

12

a,2

99056

.

2

− 49962

.

2

− (− .

2

)

79452

e

=

×100 =

%

80

.

11

a,2

− 49962

.

2

00029

.

7

− 7 00561

.

e

=

×100 =

%

076

.

0

a,2

7 00029

.

Gauss-Seidel: Ex 8.4

2

x = 2.

x = −

x =

1

,

99056

2

,

49962

.

2

2

00029

.

7

2

3

+

x +

x

+

+

3

7.85 0 1

.

2

0 2

.

2

85

.

7

(

1

.

0

)

49962

.

2

.

0 (

2

)

00029

.

7

0001

.

9

2

3

x =

=

=

= 3 00003

.

1

3

3

3

x +

x

+

3

3

.

19

1

.

0

3

3

.

0

2

3

.

19

)

00003

.

3

(

1

.

0

.

0 (

3 .

7

)

00029

499916

.

17

1

3

x =

=

=

= − .

2 499988

2

7

7

7

x +

x

+

3

.

71 4 0 3

.

3

.

0 2 3

4

.

71

.

3

(

3

.

0

)

00003

(

2

.

0

2

)

499988

.

.

69 99999

1

2

x =

=

=

= .

6 999999

3

10

10

10

00003

.

3

− 99056

.

2

e

=

×100 =

%

3157

.

0

a,3

00003

.

3

− 499988

.

2

− (−

)

49962

.

2

e

=

×100 =

%

01472

.

0

a,3

− 499988

.

2

999999

.

6

− 00029

.

7

e

=

×100 =

%

004157

.

0

a,3

999999

.

6

Gauss-Seidel: Ex 8.4

Gauss-Seidel: Ex 8.4

Jacobi Method

Convergence of Iterative

Method

Break

• After Break

– LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

LU Decomposition

Crout Decomposition

Crout Decomposition

Crout Decomposition

Crout Decomposition

Crout Decomposition

Crout Decomposition

Crout Decomposition

Example 8.6

Crout Decomposition

Crout Decomposition

Example 8.7

Example 8.7

Summary Chapter 8

Homework 9, Chapter 10

DOWNLOAD

คํานวณแนะนําให้เขียนโปรแกรม หรือใช้

MATLAB หรือใช้ Spreadsheet(Excel)

หยุด 2 ส ัปดาห์

การบ้าน ส่งต้นช่ัวโมง พุธ 20 เมษายน

End of Chapter 10

• Next Week (Wk 13)

– No Class วันจักรี

• Following Week (Wk 14)

– No Class วันสงกรานต์

• Week 15; Chapter 11

– April 20

– Numerical Differentiation and

Integration

Document Outline

Table of contents

previous page start